package com.pai4j.client.config;
import com.pai4j.client.config.interceptor.SafeClickInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ClientWebMvcConfig implements WebMvcConfigurer {

    private static final String CLINT_REQUEST_PATH_PREFIX = "/client-service/chat";

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        /**
         * 注册安全点击拦截器
         */
        registry.addInterceptor(safeClickInterceptor()).addPathPatterns(CLINT_REQUEST_PATH_PREFIX);
    }

    @Bean
    public SafeClickInterceptor safeClickInterceptor() {
        return new SafeClickInterceptor();
    }
}
